<script src="/statics/js/layer.js"></script>
<!-- 头部开始 -->
<div class="header">
<!--    <div class="header_r" style="margin-top:-8px"><img src="<?=session('loginImg')?>" width="30"></div>-->
    <div class="header_l"><a href="/index/user"></a></div>
    <div class="header_m"><?=$stitle ?: '全部订单'?></div>
</div>
<!-- 头部结束 -->

<!--全部订单开始-->
<div class="dingdan">
	<?php if($dataout){foreach($dataout AS $val){?>
    <div class="dingdan-list">
        <div class="dingdan-list-zt"><a href="/order/odetail/orderId/<?=$val['order_id']?>"><span style="padding-right: 14px;"><?=$orderStatus[$val['order_status']]?></span><i>订单号：</i><?=$val['order_id']?></a></div>
        <div class="dingdan-list-shr"><span><?=$val['order_at']?></span><i>收货人：</i><?=$val['receive_name']?></div>
        <?php if($val['goods_detail']){foreach($val['goods_detail'] AS $vals){?>
        <!--<ul>-->
            <!--<li class="dingdan-list-li1"><a href="/goods/detail/id/<?=$vals['goods_id']?>/sek/<?=$sek?>"><img src="<?=transUrl($vals['goods_pic'])?>" width="90%" height="90%"></a></li>-->
            <!--<li class="dingdan-list-li2"><a href="/goods/detail/id/<?=$vals['goods_id']?>/sek/<?=$sek?>"><?=$vals['goods_title']?><p>规格：<?=$vals['goods_attr']?></p></a>-->
            <!--<p><a href="/index/index/sek/<?=mySpreadSek($vals['biz_cust_id'])?>"><?=$vals['biz_cust_realname']?> 海外购旗舰店</a></p>-->
            <!--</li>-->
            <!--<li class="dingdan-list-li3">¥ <?=$vals['pay_price']?><p>×<?=$vals['pay_nums']?></p></li>-->
        <!--</ul>-->
		<div class="ck-tax">
			<ul>
				<li class="dingdan-list-li1"><a href="/goods/detail/id/<?=$vals['goods_id']?>/sek/<?=$sek?>"><img src="<?=transUrl($vals['goods_pic'])?>" width="90%" height="90%"></a></li>
				<li class="dingdan-list-li2"><a href="/goods/detail/id/<?=$vals['goods_id']?>/sek/<?=$sek?>"><?=$vals['goods_title']?><p>规格：<?=$vals['goods_attr']?></p ></a></li>
				<li class="dingdan-list-li3">¥ <?=$vals['pay_price']?><p>×<?=$vals['pay_nums']?></p ></li>
				<span class="dingdan-tax" onclick="taxesClick(this)">税费：￥<?=number_format($vals['goods_taxes_price']*$vals['pay_nums'],2,'.','')?></span>
			</ul>
			<div class="tax">据国家政策规定，本品适用于跨境综合税：<?=$vals['rate']*100?>%</div>
		</div>
        <?php }}?>
		<div class="dingdan-list-order">
			<span>合计：<i>¥ <?=$val['money']?></i><br /><em>含运费：￥<?=$val['order_express']?:'0.00'?> 税费￥<?=$val['order_taxes']?></em></span>共 <?=$val['sum_nums']?> 件商品
		</div>
        <!--<div class="dingdan-list-order"><span>合计<?=$vals['order_express'] > 0 ? '[含运费 '.$vals['order_express'].'元]' : ''?>：<i>¥ <?=$val['money']?></i></span>共 <?=$val['sum_nums']?> 件商品</div>-->
        <?php $refundSth = $val['order_status'] == '6' ? 1 : 0; $step1 = $val['order_status'] == '0' ? 1 : 0;$refundBool = in_array($val['order_status'],array('1','2','3')) && (!$val['success_at'] || (time() - $val['success_at']) < getSysConfig('refundDays')*24*3600 ) ? 1 : 0;?>
        <div class="dingdan-list-order2" <?=$step1 || $refundBool || $refundSth || $val['order_status'] == '2' ? '' : 'style="display:none"'?>>
        	<?php if($step1){?>
	        <a  href="/order/pay/?orderId=<?=$val['order_id']?>">立即支付</a>
	        <a href="/order/cancle/orderId/<?=$val['order_id']?>" class="putCancle">取消订单</a>
	        <?php }?>
	        <?php if($refundBool){?>
			<?php
			$getOemSum = M('OrderCollect')->where(array('order_id'=>$val['order_id'],'type'=>'2'))->count();
			if($getOemSum < 1){
			?>
	        <a href="/order/refund/orderId/<?=$val['order_id']?>">申请退款</a>
	        <?php }}?>
	        <?php if($val['order_status'] == '2'){?>
	        <a class="putReceive" href="/order/receive/orderId/<?=$val['order_id']?>">确认收货</a>
	        <?php }?>
	        <?php if($refundSth){?>
	        <a href="/order/reback/orderId/<?=$val['order_id']?>"><?=$val['refund_expressnum'] == '' ? '填写' : '查看'?>退货信息</a>
	        <?php }?>
        </div>
    </div><!--<center><hr style="border:1px solid #e5e5e5;width:95%"></center>-->
    <?php }}else{?>
    <center style="margin-top:40px;margin-bottom:40px">暂无订单</center>
    <?php }?>
</div>
<script>
$(function(){
	$('.putCancle').click(function(){
		_this = $(this);
		layer.confirm('确认取消该订单吗 ?', { btn: ['确认','取消']},       
              function(){
				$.get(_this.attr('href'),{},function(data){
					layer.msg(data.msg, {icon: data.code});
					setTimeout(function(){location.reload();},1000);
				},'json');
  			},    
	        function(){});
		return false;
	});
	$('.putReceive').click(function(){
		_this = $(this);
		layer.confirm('确认收货吗 ?', { btn: ['确认','取消']},       
              function(){
				$.get(_this.attr('href'),{},function(data){
					layer.msg(data.msg, {icon: data.code});
					setTimeout(function(){location.reload();},1000);
				},'json');
  			},    
	        function(){});
		return false;
	});
})
</script>
<!--全部订单结束-->

<div class="fiex nav"> <a class="icon-shouye" href="/index/index/sek/<?=$sek?>"><br />
  首页</a> <a class="icon-fenlei" href="/cate/main/sek/<?=$sek?>"><br />
  分类</a> <a class="icon-gouwu" href="/cart/index/sek/<?=$sek?>"><span id="cartSum"></span><br />
  购物车</a> <a class="icon-geren  fiex_on" href="/index/user/sek/<?=$sek?>"><br />
  用户中心</a> </div>
<script type="text/javascript">
	$(function(){
		cartSum();
		//AJAX请求数据
		var range = 50; //距下边界长度/单位px
		var doreturn = 1;
		var page = 1;
		var totalheight = 0;
		$(window).scroll(function(){
			var srollPos = $(window).scrollTop();
			totalheight = parseFloat($(window).height()) + parseFloat(srollPos);
			if(($(document).height()-range) <= totalheight && doreturn > 0) {
				$('.ajaxing').remove();
				doreturn = 0;
				$('.dingdan').append('<center class="ajaxing" style="margin-top:18px"><img src="/statics/images/ajaxing.gif" /></center>');
				$.post('/order/slist',{'page':(parseInt(page)+1),'orderAjax':'1','sek':'<?=$sek?>','status':'<?=I("get.status")?:"";?>'},function(data){
					$('.ajaxing').remove();
					if(data.code == '0'){
						doreturn = 0;return false;
					}else{
						doreturn = 1;
					}
					page = data.page;
					$('.dingdan').append(data.data);
				},'json');
			}
		});
	});
</script>
<script type="text/javascript">
	function taxesClick(_this){
		var tax1 = $(_this).attr('class');
		if(tax1=='dingdan-tax'){
			$(_this).parents('.ck-tax').find('.tax').slideToggle();
			$(_this).removeClass('dingdan-tax').addClass('dingdan-tax2')
		}else{
			$(_this).parents('.ck-tax').find('.tax').slideToggle();
			$(_this).removeClass('dingdan-tax2').addClass('dingdan-tax')
		}
	}
</script>
